﻿var RegexHelper = window.RegexHelper || {};

// 邮箱验证码
RegexHelper.emailRegex = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/;
// 手机号码
RegexHelper.phoneRegex = /0?(13|14|15|17|18|19)[0-9]{9}/;
// 验证码
RegexHelper.codeRegex = /^[a-zA-Z0-9]{4}$/;
// 手机验证码
RegexHelper.phoneCodeRegex = /^[0-9]{4}$/;

// 手机验证通过
RegexHelper.isPhonePass = function (phoneNum) {
    return this.phoneRegex.test(phoneNum);
}

// 邮箱验证通过
RegexHelper.isEmailPass = function (email) {
    return this.emailRegex.test(email);
}

// 普通验证码
RegexHelper.isCodePass = function (code) {
    return this.codeRegex.test(code);
}

// 手机短信验证码
RegexHelper.isPhoneCodePass = function (code) {
    return this.phoneCodeRegex.test(code);
}


RegexHelper.isPassWithPattern = function (str, pattern) {
    var regex = pattern;
    return pattern.test(str);
    
}
